﻿using LuaInterface;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class TestDownLua : MonoBehaviour {

	// Use this for initialization
	IEnumerator Start () {

        WWW www = new WWW("http://115.159.112.21/Data/lua_ui.unity3d");
        yield return www;
        if (www.isDone)
        {
            byte[] bytes = www.bytes;
            TextAsset o = www.assetBundle.LoadAsset<TextAsset>("TestUnit.lua");
            Debug.Log(o.name);

            TestPL2 p = new TestPL2();
            new LuaResLoader();
            LuaState lua = new LuaState();
            LuaBinder.Bind(lua);
            lua.Start();
            lua.DoString(o.text);
            lua["o"] = p;
            lua["test.o"] = p;

            //LuaFunction luaFunc = lua.GetFunction("test.luaFunc");
            //luaFunc.Call();
            LuaFunction luaFunc = lua.GetFunction("Main2");
            luaFunc.Call(p);

            LuaFunction luaFunc2 = lua.GetFunction("Main");
            luaFunc2.Call();

            luaFunc.Dispose();
        }
    }
	
	// Update is called once per frame
	void Update () {
		
	}
}
